package net.unesc.todo.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import net.unesc.todo.persistencia.ConexaoUtil;
import net.unesc.todo.modelo.Task;

/**
 *
 * @author Joel da Rosa
 * 2010
 */
public class TaskDao {

    public void salvar(Task task) {
        String sql = "insert into task(codigo, descricao) values (?, ?)";

        Connection c = null;
        try {
            c = ConexaoUtil.getConnection();
            PreparedStatement p = c.prepareStatement(sql);
            p.setInt(1, task.getCodigo());
            p.setString(2, task.getDescricao());
            p.execute();
            p.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
